##Replication code for Post, Alison E. and Maria Victoria Murillo. 2015. "How Investor Portfolios Shape Regulatory Outcomes: Privatized Infrastructure After Crises." World Development.  

###Code for repeated event duration models of investor exit presented in article and on-line appendix##

library(foreign)
library(survival)
library(simPH)

##Load data##
exitdata <- read.csv("investorexit.csv", header=TRUE)

##Create additional variables##
exitdata$Investor_Type3 <- relevel(exitdata$Investor_Type2, "LDC") #variable leveled so LDC the baseline category#
exitdata$Rep_Exit_Cost_Addmain <- exitdata$Other_Reg_Assets + exitdata$Sector_Brand + exitdata$Large_AR_Port #main version of reputational exit cost index#
exitdata$Reweighted_Rep <- 2*(exitdata$Other_Reg_Assets) + exitdata$Sector_Brand + exitdata$Large_AR_Port #version of reputational exit cost index that weights domestic audiences as heavily as international ones#

	#Subsets of the data#
	wat <- exitdata[exitdata$Sector=="Water",]
	elec <- exitdata[exitdata$Sector=="Electricity",]
	precrisis.entry <- exitdata[exitdata$PreCrisis_Entry==1,]
	postcrisis.entry <- exitdata[exitdata$PreCrisis_Entry==0,]


##TABLES IN THE ARTICLE##

##Table 3##

	#Model 1#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#dfbetas for Model 1#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata)
	par(mfrow=c(2,2))
	rr <- resid(cfit, type='dfbeta')
	plot(exitdata$Rep_Exit_Cost_Addmain, rr[,2], xlab="Rep Exit Cost", ylab="Influence for Rep Exit Cost") 
	identify(exitdata$Rep_Exit_Cost_Addmain, rr[,2])
	
	plot(exitdata$Diversified, rr[,1], xlab="Diversified", ylab="Influence for Diversified") 
	identify(exitdata$Diversified, rr[,1])

	plot(exitdata$Private, rr[,4], xlab="Private", ylab="Influence for Private") 
	identify(exitdata$Private, rr[,4])
	
	plot(exitdata$Fin_Exit_Cost, rr[,3], xlab="Financial Exit Cost", ylab="Influence for Financial Exit Cost") 
	identify(exitdata$Fin_Exit_Cost, rr[,3])

	##Re-run as frailty model## 
	
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost + Private*Years_Since_Crisis + frailty(Concession, distribution="gaussian") + strata(Sector) + strata(Event_Number), data=exitdata)
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out

cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost + Private*Years_Since_Crisis + frailty(Concession, distribution="gamma") + strata(Sector) + strata(Event_Number), data=exitdata)
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out	

	#Quantities of interest#
sim1 <- coxsimLinear(cfit,b="Diversified", qi="Relative Hazard", Xj=1, Xl=0)
mean(sim1$QI)
sd(sim1$QI)

sim1 <- coxsimLinear(cfit,b="Diversified", qi="First Difference", Xj=1, Xl=0) 
attributes(sim1)
sim1$QI
mean(sim1$QI)

sim1 <- coxsimLinear(cfit,b="Rep_Exit_Cost_Addmain", qi="Hazard Ratio", Xj=2, Xl=1)
mean(sim1$QI)
sd(sim1$QI)

sim1 <- coxsimLinear(cfit,b="Rep_Exit_Cost_Addmain", qi="First Difference", Xj=2, Xl=1)
mean(sim1$QI)
sd(sim1$QI)
sortedvalues <- sort(sim1$QI)

sim1 <- coxsimLinear(cfit,b="Rep_Exit_Cost_Addmain", qi="First Difference", Xj=3, Xl=2)
mean(sim1$QI)
sd(sim1$QI)

	#Model 2#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Sector_Brand + Large_AR_Port + Other_Reg_Assets + Fin_Exit_Cost  + Private*Years_Since_Crisis + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)
	
	#Model 3#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +  Investor_Type3 + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 4#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +  Domestic + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 5#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +  + PBG_1999 + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 6#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +   log(HH_2001) + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 7#
	cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis + Formal_Independence + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 8#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis + encpdn + Gov_Aligned2 + Accord_Reached + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)



##TABLES IN THE ONLINE APPENDIX##


	##Table A.I: Rate of Exit by Level of Reputational Exit Costs##

#Create data frame with one observation per lead investor#
reneg.data <- exitdata[exitdata$Investor_Year==1,]

watersector <- reneg.data[reneg.data$Sector=="Water",]
electricitysector <- reneg.data[reneg.data$Sector=="Electricity",]
precrisis.subset <- reneg.data[reneg.data$PreCrisis_Entry==1,]
postcrisis.subset <- reneg.data[reneg.data$PreCrisis_Entry==0,]

	#Electricity cases#

High_Rep <- electricitysector[electricitysector$Rep_Exit_Cost_Addmain==3,]
High_Rep_Total <- sum(High_Rep$Weights)
High_Rep_Total
Exit <- High_Rep[High_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
High_Per_Exit <- Exit_Count/High_Rep_Total ####
Exit_Count

Med_Rep <- electricitysector[electricitysector$Rep_Exit_Cost_Addmain==2,]
Med_Rep_Total <- sum(Med_Rep$Weights)
Exit <- Med_Rep[Med_Rep$Investor_Exit==1,]
Med_Rep_Total
Exit_Count <- sum(Exit$Weights)
Med_Per_Exit <- Exit_Count/Med_Rep_Total ####
Exit_Count

Low_Rep <- electricitysector[electricitysector$Rep_Exit_Cost_Addmain==1,]
Low_Rep_Total <- sum(Low_Rep$Weights)
Low_Rep_Total
Exit <- Low_Rep[Low_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
Low_Per_Exit <- Exit_Count/Low_Rep_Total ####
Exit_Count

Zero_Rep <- electricitysector[electricitysector$Rep_Exit_Cost_Addmain==0,]
Zero_Rep_Total <- sum(Zero_Rep$Weights)
Zero_Rep_Total
Exit <- Zero_Rep[Zero_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
Zero_Per_Exit <- Exit_Count/Zero_Rep_Total 
Exit_Count

	#Water cases#
High_Rep <- watersector[watersector$Rep_Exit_Cost_Addmain==3,]
High_Rep_Total <- sum(High_Rep$Weights)
High_Rep_Total
Exit <- High_Rep[High_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
High_Per_Exit <- Exit_Count/High_Rep_Total ####
Exit_Count

Med_Rep <- watersector[watersector$Rep_Exit_Cost_Addmain==2,]
Med_Rep_Total <- sum(Med_Rep$Weights)
Exit <- Med_Rep[Med_Rep$Investor_Exit==1,]
Med_Rep_Total
Exit_Count <- sum(Exit$Weights)
Med_Per_Exit <- Exit_Count/Med_Rep_Total ####
Exit_Count

Low_Rep <- watersector[watersector$Rep_Exit_Cost_Addmain==1,]
Low_Rep_Total <- sum(Low_Rep$Weights)
Low_Rep_Total
Exit <- Low_Rep[Low_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
Low_Per_Exit <- Exit_Count/Low_Rep_Total ####
Exit_Count

Zero_Rep <- watersector[watersector$Rep_Exit_Cost_Addmain==0,]
Zero_Rep_Total <- sum(Zero_Rep$Weights)
Zero_Rep_Total
Exit <- Zero_Rep[Zero_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
Zero_Per_Exit <- Exit_Count/Zero_Rep_Total 
Exit_Count

##Table A.III. Distribution of Cases across values of independent variables table##
High_Rep <- reneg.data[reneg.data$Rep_Exit_Cost_Addmain==3 | reneg.data$Rep_Exit_Cost_Addmain==2,]
High_Rep_Total <- sum(High_Rep$Weights)
High_Rep_Total

Low_Rep <- reneg.data[reneg.data$Rep_Exit_Cost_Addmain==0 | reneg.data$Rep_Exit_Cost_Addmain==1,]
Low_Rep_Total <- sum(Low_Rep$Weights)
Low_Rep_Total

High_and_Diversified <- High_Rep[High_Rep$Diversified==1,]
High_and_Diversified_Total <- sum(High_and_Diversified$Weights)
High_and_Diversified_Total

High_not_Diversified <- High_Rep[High_Rep$Diversified==0,]
High_not_Diversified_Total <- sum(High_not_Diversified$Weights)
High_not_Diversified_Total


Low_and_Diversified <- Low_Rep[Low_Rep$Diversified==1,]
Low_and_Diversified_Total <- sum(Low_and_Diversified$Weights)
Low_and_Diversified_Total

Low_not_Diversified <- Low_Rep[Low_Rep$Diversified==0,]
Low_not_Diversified_Total <- sum(Low_not_Diversified$Weights)
Low_not_Diversified_Total




##Table A.V. Conditional Gap Time Cox Proportional Hazard Analysis of Investor Exit from Electricity and W&S Contracts, 2003-2009 (with sector dummies) 


	#Model 1#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis + cluster(Concession) + cluster(Province) + Sector*Years_Since_Crisis + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)  #Sector significant#
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 2#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Sector_Brand + Large_AR_Port + Other_Reg_Assets + Fin_Exit_Cost  + Private*Years_Since_Crisis + cluster(Concession) + cluster(Province) + Sector + strata(Event_Number), weights=Weights, data=exitdata) #water sector significant#
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 3#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +  Investor_Type3 + cluster(Concession) + cluster(Province) + Sector + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit) #water insignificant#
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 4#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +  Domestic + cluster(Concession) + cluster(Province) + Sector*Years_Since_Crisis + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)  #water significant#
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 5#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +   + PBG_1999 + cluster(Concession) + cluster(Province) + Sector*Years_Since_Crisis + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit) #water insignificant#
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 6#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis +  + log(HH_2001) + cluster(Concession) + cluster(Province) + Sector*Years_Since_Crisis + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit) #water sigificant#
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 7#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis  + Formal_Independence + cluster(Concession) + cluster(Province) + Sector*Years_Since_Crisis + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out  #Sector insignificant if included#
extractAIC(cfit)

cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private*Years_Since_Crisis + encpdn + Gov_Aligned2 + Accord_Reached + cluster(Concession) + cluster(Province) + Sector*Years_Since_Crisis + strata(Event_Number), weights=Weights, data=exitdata) #Water insignificant#
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)


	##Table A.VII. Conditional Gap Time Proportional Hazard Analysis of Investor Exit from Electircity and W&S Contracts, 2003-2009 (with re-weighted reputational exit cost index)  
	

	#Model 1#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Reweighted_Rep + Fin_Exit_Cost  + Private*Years_Since_Crisis + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 2#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Sector_Brand + Large_AR_Port + Other_Reg_Assets + Fin_Exit_Cost  + Private*Years_Since_Crisis + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 3#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Reweighted_Rep + Fin_Exit_Cost  + Private*Years_Since_Crisis +  Investor_Type3 + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit) 
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 4#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Reweighted_Rep + Fin_Exit_Cost  + Private*Years_Since_Crisis +  Domestic + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 5#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Reweighted_Rep + Fin_Exit_Cost  + Private*Years_Since_Crisis + PBG_1999 + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)

	#Model 6#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Reweighted_Rep + Fin_Exit_Cost  + Private*Years_Since_Crisis + log(HH_2001) + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)


	#Model 7#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Reweighted_Rep + Fin_Exit_Cost  + Private*Years_Since_Crisis  + Formal_Independence + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)
	
	#Model 8#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Reweighted_Rep + Fin_Exit_Cost  + Private*Years_Since_Crisis + encpdn + Gov_Aligned2 + Accord_Reached + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out
extractAIC(cfit)


	##Table A.VIII. Conditional Gap Time Cox Proportional Hazard Analysis of Investor Exit From Electricity and W&S Contracts, 2003-2009 (Results by Sector)	

#Model 1#  #We have not included "years since crisis" since we do not need it to correct proportionality problems; also, including it prevents the model from converging#

	#electricity sector#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=elec) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out

	#water sector#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=wat) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out

	#electricity: reputational cost interacted with domestic ownership#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain*Domestic + Fin_Exit_Cost  + Private + strata(Event_Number) + cluster(Concession) + cluster(Province), weights=Weights, data=elec) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out

	#water: reputational cost interacted with domestic ownership#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain*Domestic + Fin_Exit_Cost  + Private + strata(Event_Number) + cluster(Concession) + cluster(Province), weights=Weights, data=wat) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out


	##Table A.XI. Conditional Gap Time Cox Proportional Hazard Analysis of Investor Exit from Electricity and W&S Contracts, 2003-2009 (Pre-Crisis Entrants)

#Interactions#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain*PreCrisis_Entry + Fin_Exit_Cost  + Private + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=exitdata) 
zph.out <- cox.zph(cfit)
summary(cfit)
zph.out

	#Model 1#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #Proportionality problem for reputational exit cost in this specification; however, normal corrections do not work, so we need to be circumspect in interpreting coefficients#
summary(cfit)
zph.out

	#Model 2#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Sector_Brand + Large_AR_Port + Other_Reg_Assets + Fin_Exit_Cost  + Private + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #No proportionality problems#
summary(cfit)
zph.out

	#Model 3#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private + Investor_Type3 + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #No proportionality problems#
summary(cfit)
zph.out

#Model 4#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private + Domestic + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #No proportionality problems#
summary(cfit)
zph.out

#Model 5#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private +  PBG_1999+ cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #No proportionality problems#
summary(cfit)
zph.out

#Model 6#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private +  log(HH_2001)+ cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #No proportionality problems#
summary(cfit)
zph.out

#Model 7#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private +  Formal_Independence + cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #Proportionality problem for Reputational exit cost measure#
summary(cfit)
zph.out

	#Model 8#
cfit <- coxph(Surv(GapStart,GapStop,Exit_In_Year) ~ Diversified + Rep_Exit_Cost_Addmain + Fin_Exit_Cost  + Private + Gov_Aligned2 + encpdn + Accord_Reached+  cluster(Concession) + cluster(Province) + strata(Sector) + strata(Event_Number), weights=Weights, data=precrisis.entry) 
zph.out <- cox.zph(cfit) #major proportionality problems; note, shouldn't be worried about statistical sign for portfolio variables because post treatment bias may be a problem here#
summary(cfit)
zph.out



#Table A.XII. Rates of Exit for Post-Crisis Investors#

	#Pre vs. postCrisis Entry and Rep Exit Costs
	High_Rep <- postcrisis.subset[postcrisis.subset$Rep_Exit_Cost_Addmain==3,]
High_Rep_Total <- sum(High_Rep$Weights)
High_Rep_Total
Exit <- High_Rep[High_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
High_Per_Exit <- Exit_Count/High_Rep_Total ####
Exit_Count

Med_Rep <- postcrisis.subset[postcrisis.subset$Rep_Exit_Cost_Addmain==2,]
Med_Rep_Total <- sum(Med_Rep$Weights)
Exit <- Med_Rep[Med_Rep$Investor_Exit==1,]
Med_Rep_Total
Exit_Count <- sum(Exit$Weights)
Med_Per_Exit <- Exit_Count/Med_Rep_Total ####
Exit_Count

Low_Rep <- postcrisis.subset[postcrisis.subset$Rep_Exit_Cost_Addmain==1,]
Low_Rep_Total <- sum(Low_Rep$Weights)
Low_Rep_Total
Exit <- Low_Rep[Low_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
Low_Per_Exit <- Exit_Count/Low_Rep_Total ####
Exit_Count

Zero_Rep <- postcrisis.subset[postcrisis.subset$Rep_Exit_Cost_Addmain==0,]
Zero_Rep_Total <- sum(Zero_Rep$Weights)
Zero_Rep_Total
Exit <- Zero_Rep[Zero_Rep$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
Zero_Per_Exit <- Exit_Count/Zero_Rep_Total 
Exit_Count

#Pre vs. postCrisis Entry and Diversification
	Diversifiedsubset <- postcrisis.subset[postcrisis.subset$Diversified==1,]
Diversified_Total <- sum(Diversifiedsubset$Weights)
Diversified_Total
Exit <- Diversifiedsubset[Diversifiedsubset$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
Div_Per_Exit <- Exit_Count/Diversified_Total ####
Exit_Count

UnDiversifiedsubset <- postcrisis.subset[postcrisis.subset$Diversified==0,]
UnDiversified_Total <- sum(UnDiversifiedsubset$Weights)
UnDiversified_Total
Exit <- UnDiversifiedsubset[UnDiversifiedsubset$Investor_Exit==1,]
Exit_Count <- sum(Exit$Weights)
UnDiv_Per_Exit <- Exit_Count/UnDiversified_Total ####
Exit_Count


